package longcaisuyun.longcai.com.net;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/22.
 * 答题题库
 */
@HttpInlet(Net.DATI)
public class PostDaTi extends WHAsyPost<PostDaTi.Info>{

    public PostDaTi(AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected Info parser(JSONObject object) {
        Info info=new Info();
        info.message=object.optString("message");
        JSONArray array = object.optJSONArray("list");
        if (array != null) {
            for (int j = 0; j < array.length(); j++) {
                DaTi dati=new DaTi();
                dati.setId(array.optJSONObject(j).optString("id"));
                dati.setTitle(array.optJSONObject(j).optString("title"));
                dati.setOptiona(array.optJSONObject(j).optString("optiona"));
                dati.setOptionb(array.optJSONObject(j).optString("optionb"));
                dati.setOptionc(array.optJSONObject(j).optString("optionc"));
                dati.setOptiond(array.optJSONObject(j).optString("optiond"));
                dati.setChecked("");
                info.list.add(dati);
            }
        }
        return info;
    }

    public class Info{
        public String message;
        public List<DaTi> list=new ArrayList<>();
    }
    public class DaTi implements Serializable{
        private String id;
        private String title;
        private String optiona;
        private String optionb;
        private String optionc;
        private String optiond;
        private String checked;

        @Override
        public String toString() {
            return "{" +
                    "questionid:\"" + id + '\'' +
                    ", optiona:'" + optiona + '\'' +
                    ", optionb:'" + optionb + '\'' +
                    ", optionc:'" + optionc + '\'' +
                    ", optiond:'" + optiond + '\'' +
                    ", checked:'" + checked + '\'' +
                    '}';
        }

        public String getChecked() {
            return checked;
        }

        public void setChecked(String checked) {
            this.checked = checked;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getOptiona() {
            return optiona;
        }

        public void setOptiona(String optiona) {
            this.optiona = optiona;
        }

        public String getOptionb() {
            return optionb;
        }

        public void setOptionb(String optionb) {
            this.optionb = optionb;
        }

        public String getOptionc() {
            return optionc;
        }

        public void setOptionc(String optionc) {
            this.optionc = optionc;
        }

        public String getOptiond() {
            return optiond;
        }

        public void setOptiond(String optiond) {
            this.optiond = optiond;
        }
    }

}
